﻿@using E5_KhuyenMaiVang.Models;
@model IEnumerable<DEAL>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    List<COMPANY> companies = ViewBag.Companies;
    double TongDoanhThu = 0;
    int count = 0;
    int SelectedIndex = ViewBag.SelectedIndex;
}

@section menu
{
    <h3>Admin</h3>
    <ul class="nav">        
        <li><a href="@Url.Action("TKDT_Thang","Admin")">Doanh thu theo tháng</a></li>
        <li><a href="@Url.Action("TKDT_KhuyenMai","Admin")">Doanh thu khuyến mãi</a></li>
        <li><a href="@Url.Action("TKDT_DoanhNghiep","Admin")" style="text-decoration:underline; font-weight:bold;">Doanh thu doanh nghiệp</a></li>
   </ul>
}



<div class="top-bar">                   
    <h1>THỐNG KÊ DOANH THU</h1>
    <div class="breadcrumbs"><a href="#">Thống kê</a> / <a href="#">Doanh thu doanh nghiệp</a></div>
</div>
<form  method="post" action="@Url.Action("SearchTKDT_DoanhNghiep","Admin")">
<div class="select-bar">
    <label>
            <select size="1" id="select" name="CompanyID">
            <option value="0">Tất cả</option>
        	@foreach (var item in companies)
            {
                if (item.CompanyID != SelectedIndex)
                {
                    <option value="@item.CompanyID">@item.CompanyName</option>
                }
                else { 
                    <option value="@item.CompanyID" selected="true">@item.CompanyName</option>
                }
            }
        </select> 
    </label>
    <label>
        <input type="submit" name="Submit" value="Search" />
    </label>
</div>
</form>              
<div class="table">
<table class="listing" cellpadding="0" cellspacing="0">
        <tr>
            <th width="72">Số thứ tự</th>
            <th width="179">Tên khuyến mãi</th>
            <th width="179">Giá</th>
            <th width="114">Ngày đăng</th>
            <th width="60">Ngày hết hạn</th>
            <th width="60">Tình trạng</th>
            <th width="99">Số lương bán</th>
            <th width="87">Tiền thu</th>
        </tr>
        @foreach (var item in Model)
        {
            count++;
            double MoneySold = item.SoldQuantity * item.Price;
            TongDoanhThu += MoneySold;
        <tr>
            <td class="style1">@count</td>
            <td>@item.DealName</td>
            <td>@item.Price</td>
            <td>@item.StartDate</td>
            <td>@item.EndDate</td>
            <td>@item.DEAL_STATUS.StatusName</td>
            <td>@item.SoldQuantity</td>
            <td>@MoneySold</td>                           
        </tr>
        }
    </table>
    <div class="select">
        <strong>Tổng doanh thu: </strong>
        <strong style="color:#F00;">@TongDoanhThu</strong>
    </div>
</div>
            